package persistence;

import java.sql.*;

import oracle.jdbc.pool.OracleDataSource;

public class DBConnection {
	
	private static DBConnection db = null;
	private Connection db_conn = null;
	
	private DBConnection() throws SQLException{
		
		OracleDataSource ods;
		
		db = new DBConnection();
		
		try {
			ods = new OracleDataSource();
			ods.setURL("jdbc:oracle:thin:SYS/c4b3l0tjg@localhost:1158:ORCL");
			db_conn = ods.getConnection();			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public synchronized static DBConnection getInstance() throws SQLException{
	     if (db == null){
	    	 try {
	    		 db = new DBConnection();
			} catch (SQLException e) {
				e.printStackTrace();
			}	       
	     }
	     return db;
	  }

	public Connection getDb_conn() {
		return db_conn;
	}
	
}
